package com.gjy.minio.convert;

import com.gjy.minio.domain.BucketInfo;
import io.minio.messages.Bucket;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-09-04 20:20:58
 */
@Component(value = "bucketConvert")
public class BucketConvert {

    public List<BucketInfo> convert(List<Bucket> bucket) {
        return bucket.stream()
                .map(b -> {
                    BucketInfo info = new BucketInfo();
                    info.setName(b.name());
                    info.setCreationDate(b.creationDate());
                    return info;
                })
                .collect(Collectors.toList());
    }
}
